package com.my.study.lock;

import java.util.concurrent.TimeUnit;

public class LockDemo {

    public static void main(String[] args) {
        // synchronized可重入演示
        System.out.println("====================synchronized可重入演示==================");
        TestLock testLock = new TestLock();
        new Thread(()->{testLock.sendSMS();},"t1").start();
        new Thread(()->{testLock.sendSMS();},"t2").start();
        try {
            TimeUnit.SECONDS.sleep(2);
            System.out.println("====================ReentrantLock可重入演示==================");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        // ReentrantLock可重入演示
        new Thread(()->{testLock.get();},"t3").start();
        new Thread(()->{testLock.get();},"t4").start();
    }
}
